home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: netcom.com!mikenann
- From: Michael Glassman and Ann Ross <mikenann@netcom.com>
- Subject: Re: C++ keyword
- Content-Type: text/plain; charset=us-ascii
- Message-ID: <3147CBC6.7CA1@netcom.com>
- Sender: mikenann@netcom21.netcom.com
- Content-Transfer-Encoding: 7bit
- Organization: NETCOM On-line Communication Services (408 261-4700 guest)
- References: <mwoods-1403961501550001@ou048057.otago.ac.nz>
- Mime-Version: 1.0
- Date: Thu, 14 Mar 1996 07:33:26 GMT
- X-Mailer: Mozilla 2.0 (Win16; I)
-
- Matt B. Woods wrote:
- >
- > I am fairly new to C++ and I have just come across the keyword 'throw'.
- > As I cannot find a reference to this keyword I assume I must be reading
- > the wrong books. Can anyone tell me what 'throw' means? Even better
- > could someone recommend a good complete reference to the C++ language?
- >
-
- Very briefly:
- Throw is the C++ keyword to raise exceptions. Throw with an argument raises the
- exception designated by the argument; throw without an argument raises the
- currently caught exception. Throw without an argument can only be used within a
- catch block.
-
- Simple example:
-
- try
- {
- // do some stuff
- throw anException;
- }
- catch( ExceptionType& caughtException )
- {
- // handle exceptions of type ExceptionType
- }
- catch(...)
- {
- // handle all other exceptions
- }
-
- My favorite 'complete reference to the C++ language' is The Annotated C++
- Reference Manual by Ellis and Stroustrup. It is usually refered to as the ARM.
-
- Michael Glassman
-